<template>
  <div>
    <el-form ref="form" :model="user" label-width="60px" size="normal">
      <el-form-item label="登录名">
        <el-input v-model="user.username" />
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="user.password" />
      </el-form-item>
      <el-form-item label="昵称">
        <el-input v-model="user.nickName" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" size="normal" @click="onSubmit">提交</el-button>
        <el-button size="normal" @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
// import aboutApi from '@/api/about'
import { save } from '@/api/user'
// import Tinymce from '@/components/Tinymce/index'
export default {
  components: {
    // Tinymce
  },
  data() {
    return {
      user: {}
    }
  },
  mounted() {
  },
  created() {
    this.user = {}
  },
  methods: {
    onSubmit() {
      save(this.user).then(res => {
        // console.log(res)
        if (res.code !== 20000) {
          this.$message.error(res.message)
          this.$emit('fetchData')
          this.$emit('closeAddDialog')
          this.user = {}
        } else {
          this.$message.success(res.message)
          this.$emit('fetchData')
          this.$emit('closeAddDialog')
          this.user = {}
        }
      })
    },
    onCancel() {
      this.$emit('closeAddDialog')
    }
  }
}
</script>
